import { Meta, Source } from '@storybook/blocks';

<Meta title="HOOKS/useSubscribeEntity" />

# useSubscribeEntity()
###### `useSubscribeEntity(entityId: EntityName)`
This will subscribe to a single entity and only return an updated getEntity function when the entity changes.

<b>NOTE:</b> This hook is already connected to the useEntity hook and returned as part of the entity object so you may never need to use this directly.

### Example Usage

<Source dark code={`
import { HassConnect, useSubscribeEntity } from '@hakit/core';
function Office() {
  const getEntity = useSubscribeEntity('light.some_light');
  const entity = getEntity();
  return <div>
    {entity.state}
  </div>
}
function App() {
  return <HassConnect hassUrl="http://localhost:1234">
    <Office />
  </HassConnect>
}
`} />

